import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'tag'
})
export class TagPipe implements PipeTransform {

  transform(tagId: number): string {
    const tagList=this.getTagList();
    const tag=tagList.find(item=>tagId==item.id);
    return tag&&tag.name;
  }

  getTagList():{id:number,name:string}[]{
    const taglist=JSON.parse(localStorage.getItem('tagList'))||[];
    return taglist;
  }

}
